/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kungkhies.persistence.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author clayton
 */
@Entity 
@Table(name = "kungkhie")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "Kungkhie.findAll", query = "SELECT k FROM Kungkhie k"),
    @NamedQuery(name = "Kungkhie.findByKungkhieId", query = "SELECT k FROM Kungkhie k WHERE k.kungkhieId = :kungkhieId"),
    @NamedQuery(name = "Kungkhie.findByPackage1", query = "SELECT k FROM Kungkhie k WHERE k.package1 = :package1"),
    @NamedQuery(name = "Kungkhie.findByVersionCode", query = "SELECT k FROM Kungkhie k WHERE k.versionCode = :versionCode"),
    @NamedQuery(name = "Kungkhie.findByDisplayName", query = "SELECT k FROM Kungkhie k WHERE k.displayName = :displayName"),
    @NamedQuery(name = "Kungkhie.findByLang", query = "SELECT k FROM Kungkhie k WHERE k.lang = :lang"),
    @NamedQuery(name = "Kungkhie.findBySubject", query = "SELECT k FROM Kungkhie k WHERE k.subject = :subject"),
    @NamedQuery(name = "Kungkhie.findByTopic", query = "SELECT k FROM Kungkhie k WHERE k.topic = :topic"),
    @NamedQuery(name = "Kungkhie.findByAcademicLevel", query = "SELECT k FROM Kungkhie k WHERE k.academicLevel = :academicLevel"),
    @NamedQuery(name = "Kungkhie.findBySubmitted", query = "SELECT k FROM Kungkhie k WHERE k.submitted = :submitted")
})
public class Kungkhie implements Serializable 
{
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "kungkhie_id")
    private Long kungkhieId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 767)
    @Column(name = "package")
    private String package1;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1024)
    @Column(name = "version_code")
    private String versionCode;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1024)
    @Column(name = "display_name")
    private String displayName;
    @Lob
    @Size(max = 16777215)
    @Column(name = "description")
    private String description;
    @Size(max = 3)
    @Column(name = "lang")
    private String lang;
    @Size(max = 1024)
    @Column(name = "subject")
    private String subject;
    @Size(max = 1024)
    @Column(name = "topic")
    private String topic;
    @Column(name = "academic_level")
    private Short academicLevel;
    @Basic(optional = false)
    @NotNull
    @Column(name = "submitted")
    @Temporal(TemporalType.TIMESTAMP)
    private Date submitted;
    @JoinTable(name = "prereqs", joinColumns =
    {
        @JoinColumn(name = "kungkhie_id", referencedColumnName = "kungkhie_id")
    }, inverseJoinColumns =
    {
        @JoinColumn(name = "package", referencedColumnName = "package")
    })
    @ManyToMany
    private Collection<Kungkhie> kungkhieCollection;
    @ManyToMany(mappedBy = "kungkhieCollection")
    private Collection<Kungkhie> kungkhieCollection1;
    @JoinTable(name = "kungkhie_category", joinColumns =
    {
        @JoinColumn(name = "kungkhie_id", referencedColumnName = "kungkhie_id")
    }, inverseJoinColumns =
    {
        @JoinColumn(name = "category_id", referencedColumnName = "category_id")
    })
    @ManyToMany
    private Collection<Category> categoryCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kungkhie")
    private Collection<Tags> tagsCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kungkhieId")
    private Collection<KungkhieImpl> kungkhieImplCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kungkhie")
    private Collection<KungkhieKnode> kungkhieKnodeCollection;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "kungkhie")
    private UploadStats uploadStats;
    @JoinColumn(name = "publisher_id", referencedColumnName = "kungkher_id")
    @ManyToOne(optional = false)
    private Kungkher publisherId;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "kungkhie")
    private DownloadStats downloadStats;

    public Kungkhie()
    {
    }

    public Kungkhie(Long kungkhieId)
    {
        this.kungkhieId = kungkhieId;
    }

    public Kungkhie(Long kungkhieId, String package1, String versionCode, String displayName, Date submitted)
    {
        this.kungkhieId = kungkhieId;
        this.package1 = package1;
        this.versionCode = versionCode;
        this.displayName = displayName;
        this.submitted = submitted;
    }

    public Long getKungkhieId()
    {
        return kungkhieId;
    }

    public void setKungkhieId(Long kungkhieId)
    {
        this.kungkhieId = kungkhieId;
    }

    public String getPackage1()
    {
        return package1;
    }

    public void setPackage1(String package1)
    {
        this.package1 = package1;
    }

    public String getVersionCode()
    {
        return versionCode;
    }

    public void setVersionCode(String versionCode)
    {
        this.versionCode = versionCode;
    }

    public String getDisplayName()
    {
        return displayName;
    }

    public void setDisplayName(String displayName)
    {
        this.displayName = displayName;
    }

    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public String getLang()
    {
        return lang;
    }

    public void setLang(String lang)
    {
        this.lang = lang;
    }

    public String getSubject()
    {
        return subject;
    }

    public void setSubject(String subject)
    {
        this.subject = subject;
    }

    public String getTopic()
    {
        return topic;
    }

    public void setTopic(String topic)
    {
        this.topic = topic;
    }

    public Short getAcademicLevel()
    {
        return academicLevel;
    }

    public void setAcademicLevel(Short academicLevel)
    {
        this.academicLevel = academicLevel;
    }

    public Date getSubmitted()
    {
        return submitted;
    }

    public void setSubmitted(Date submitted)
    {
        this.submitted = submitted;
    }

    @XmlTransient
    public Collection<Kungkhie> getKungkhieCollection()
    {
        return kungkhieCollection;
    }

    public void setKungkhieCollection(Collection<Kungkhie> kungkhieCollection)
    {
        this.kungkhieCollection = kungkhieCollection;
    }

    @XmlTransient
    public Collection<Kungkhie> getKungkhieCollection1()
    {
        return kungkhieCollection1;
    }

    public void setKungkhieCollection1(Collection<Kungkhie> kungkhieCollection1)
    {
        this.kungkhieCollection1 = kungkhieCollection1;
    }

    @XmlTransient
    public Collection<Category> getCategoryCollection()
    {
        return categoryCollection;
    }

    public void setCategoryCollection(Collection<Category> categoryCollection)
    {
        this.categoryCollection = categoryCollection;
    }

    @XmlTransient
    public Collection<Tags> getTagsCollection()
    {
        return tagsCollection;
    }

    public void setTagsCollection(Collection<Tags> tagsCollection)
    {
        this.tagsCollection = tagsCollection;
    }

    @XmlTransient
    public Collection<KungkhieImpl> getKungkhieImplCollection()
    {
        return kungkhieImplCollection;
    }

    public void setKungkhieImplCollection(Collection<KungkhieImpl> kungkhieImplCollection)
    {
        this.kungkhieImplCollection = kungkhieImplCollection;
    }

    @XmlTransient
    public Collection<KungkhieKnode> getKungkhieKnodeCollection()
    {
        return kungkhieKnodeCollection;
    }

    public void setKungkhieKnodeCollection(Collection<KungkhieKnode> kungkhieKnodeCollection)
    {
        this.kungkhieKnodeCollection = kungkhieKnodeCollection;
    }

    public UploadStats getUploadStats()
    {
        return uploadStats;
    }

    public void setUploadStats(UploadStats uploadStats)
    {
        this.uploadStats = uploadStats;
    }

    public Kungkher getPublisherId()
    {
        return publisherId;
    }

    public void setPublisherId(Kungkher publisherId)
    {
        this.publisherId = publisherId;
    }

    public DownloadStats getDownloadStats()
    {
        return downloadStats;
    }

    public void setDownloadStats(DownloadStats downloadStats)
    {
        this.downloadStats = downloadStats;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (kungkhieId != null ? kungkhieId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Kungkhie))
        {
            return false;
        }
        Kungkhie other = (Kungkhie) object;
        if ((this.kungkhieId == null && other.kungkhieId != null) || (this.kungkhieId != null && !this.kungkhieId.equals(other.kungkhieId)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "com.kungkhies.persistence.entities.Kungkhie[ kungkhieId=" + kungkhieId + " ]";
    }

}
